package com.iRomantic.domain.entity;

import java.util.List;
import java.util.UUID;

import com.iRomantic.config.Constant;
import com.jfinal.plugin.activerecord.Model;

public class HotelPicture extends Model<HotelPicture>{

	private static final long serialVersionUID = -4020667303245075830L;
	
	public static final HotelPicture DAO = new HotelPicture();
	
	public boolean save(){
		this.set("id",UUID.randomUUID().toString());
		return super.save();
	}
	
	/**
	 * 根据现场ID查询现场图片
	 * @param hotelId
	 * @return
	 */
	public List<HotelPicture> findByHotelId(String hotelId){
		return this.find("select * from t_hotel_picture where hotelId=?",hotelId);
	}
	
	/**
	 * 设置资源全路径
	 * @param list
	 */
	public void setOSSPath(HotelPicture picture){
		picture.set("url", Constant.OSS_PATH+Constant.HOTEL_PICTURE+picture.getStr("hotelId")+"/"+picture.get("url"));
	}

}
